package com.work.formaldehyde.activityadapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.work.formaldehyde.R;
import com.work.formaldehyde.model.GetAddressModel;
import com.work.formaldehyde.model.WuLiuModel;

import java.util.ArrayList;

public class WuLiuAdapter extends BaseAdapter {
    ArrayList<WuLiuModel.list> lists;
    Context context;

    public WuLiuAdapter(
            ArrayList<WuLiuModel.list> lists, Context context) {
        // TODO Auto-generated constructor stub
        this.lists = lists;
        this.context = context;
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return lists != null ? lists.size() : 0;
    }

    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return lists != null ? lists.get(position) : 0;
    }

    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub
        convertView = LayoutInflater.from(context).inflate(R.layout.item_wuliulist, null);
        init i = new init();
        i.wuliu_time_top = convertView.findViewById(R.id.wuliu_time_top);
        i.wuliu_time = convertView.findViewById(R.id.wuliu_time);
        i.wuliu_xiaoxi = convertView.findViewById(R.id.wuliu_xiaoxi);
        i.zhuangtaitu = convertView.findViewById(R.id.zhuangtaitu);
        if (position == 0) {
            i.zhuangtaitu.setImageResource(R.mipmap.wl);
            i.wuliu_time_top.setTextColor(context.getResources().getColor(R.color.home_bottom_text_color_ischeck));
            i.wuliu_time.setTextColor(context.getResources().getColor(R.color.home_bottom_text_color_ischeck));
            i.wuliu_xiaoxi.setTextColor(context.getResources().getColor(R.color.home_bottom_text_color_ischeck));
        }
        String time = lists.get(position).getDatetime();
        i.wuliu_time_top.setText(time.substring(0, 9));
        i.wuliu_time.setText(time.substring(10, 18));
        i.wuliu_xiaoxi.setText(lists.get(position).getRemark());
        convertView.setTag(i);
        return convertView;
    }

    public static class init {
        //首页list的子控件
        TextView wuliu_time_top, wuliu_time, wuliu_xiaoxi;
        ImageView zhuangtaitu;
    }
}

